home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Dev / misc / LOCCounter.lha / LOCCounter / src / FileCount.cpp < prev    next >
C/C++ Source or Header  |  2004-08-18  |  1KB  |  92 lines

  1. /****************************************************************************
  2. *
  3. * $RCSfile: FileCount.cpp $
  4. * $Revision: 2.6 $
  5. * $Date: 2004/08/18 20:59:42 $
  6. * $Author: ssolie $
  7. *
  8. *****************************************************************************
  9. *
  10. * Copyright (c) 2004 Steven Solie.  All Rights Reserved.
  11. *
  12. *****************************************************************************
  13. *
  14. * FileCount component
  15. */
  16. #include "FileCount.h"
  17.  
  18. #include <cstring>
  19.  
  20.  
  21. FileCount::FileCount(const char* name, bool mode) :
  22.     m_loc(0),
  23.     m_loc_added(0),
  24.     m_loc_deleted(0),
  25.     m_diff_mode(mode)
  26. {
  27.     std::strncpy(m_name, name, MAX_FILE_NAME_LEN);
  28.     m_name[MAX_FILE_NAME_LEN - 1] = '\0';
  29. }
  30.  
  31.  
  32. FileCount::~FileCount()
  33. {
  34. }
  35.  
  36.  
  37. FileCount& FileCount::operator +=(uint32 loc)
  38. {
  39.     if ( m_diff_mode )  {
  40.         m_loc_added += loc;
  41.     }
  42.     else  {
  43.         m_loc += loc;
  44.     }
  45.  
  46.     return *this;
  47. }
  48.  
  49.  
  50. FileCount& FileCount::operator -=(uint32 loc)
  51. {
  52.     if ( m_diff_mode )  {
  53.         m_loc_deleted += loc;
  54.     }
  55.     else  {
  56.         m_loc -= loc;
  57.     }
  58.  
  59.     return *this;
  60. }
  61.  
  62.  
  63. const char* FileCount::getName() const
  64. {
  65.     return m_name;
  66. }
  67.  
  68.  
  69. uint32 FileCount::getCount() const
  70. {
  71.     return m_loc;
  72. }
  73.  
  74.  
  75. uint32 FileCount::getAddedCount() const
  76. {
  77.     return m_loc_added;
  78. }
  79.  
  80.  
  81. uint32 FileCount::getDeletedCount() const
  82. {
  83.     return m_loc_deleted;
  84. }
  85.  
  86.  
  87. bool FileCount::diffMode() const
  88. {
  89.     return m_diff_mode;
  90. }
  91.  
  92.